/*
 * @Author: your name
 * @Date: 2022-03-29 22:39:39
 * @LastEditTime: 2022-04-29 11:11:25
 * @LastEditors: Please set LastEditors
 * @Description: 账号相关
 * @FilePath: \blog-api\src\user\user.controller.ts
 */
import { Controller, Get, Post, Body, Patch, Param, Delete, UseGuards, UseInterceptors, ClassSerializerInterceptor } from '@nestjs/common';
import { AuthGuard } from '@nestjs/passport';
import { UserService } from './user.service';
import { CreateUserDto, LoginDto } from './dto/create-user.dto';

import { User } from './entities/user.entity';

import { ApiTags, ApiOperation } from '@nestjs/swagger';

@ApiTags("总后台账号相关")
@Controller('user')
export class UserController {
  constructor(private readonly userService: UserService) {}
  @ApiOperation({ summary: '注册账号' })
  @Post('register')
  register(@Body() createUser: CreateUserDto): Promise<User> {
    return this.userService.create(createUser);
  }

  @ApiOperation({ summary: '登录账号' })
  @UseGuards(AuthGuard('local'))
  // @UseInterceptors(ClassSerializerInterceptor);
  @Post('login')
  login(@Body() createUser: LoginDto): Promise<any> {
    return this.userService.login(createUser);
  }

  @ApiOperation({ summary: '查询用户信息' })
  // @UseInterceptors(ClassSerializerInterceptor);
  @Post('admin_info')
  adminInfo(): Promise<any> {
    return this.userService.admin_info();
  }
}
